import random

import vex

from .nodes import *
from .transitions import *

#---------------- Emotion Macros from VEXCode ----------------

class ActHappy(ActionNode):
    def setup(self):
        #         ShowEmoji(vex.EmojiType.HAPPY)                                =T(0.5)=>
        # 	PlaySound(vex.SoundType.ACT_HAPPY)                            =T(0.115)=>
        #         
        #         ShowEmoji(vex.EmojiType.HAPPY, vex.EmojiLookType.LOOK_RIGHT)  =N=>
        # 	Glow(vex.Color.YELLOW)                                        =N=>
        #         Turn(-4, 100)                                                 =C=>
        # 	Glow(vex.Color.WHITE)                                         =N=>
        #         ShowEmoji(vex.EmojiType.HAPPY, vex.EmojiLookType.LOOK_LEFT)   =N=>
        #         Turn(8, 100)                                                  =C=>
        # 	Glow(vex.Color.YELLOW)                                        =N=>
        #         ShowEmoji(vex.EmojiType.HAPPY, vex.EmojiLookType.LOOK_RIGHT)  =N=>
        #         Turn(-4, 100)                                                 =C=>
        # 	StateNode()                                                   =T(0.1)=> loop
        # 
        #         loop: Iterate(3)
        # 	loop                                                          =D=> 
        #           ShowEmoji(vex.EmojiType.QUIET)                              =N=>
        #   	  Glow(vex.Color.WHITE)                                       =N=>
        #           MoveFor(1, 90)                                              =C=>
        #           ShowEmoji(vex.EmojiType.HAPPY)                              =N=>
        #           Glow(vex.Color.YELLOW)                                      =N=>
        #           MoveFor(1, -90)                                             =CNext=> loop
        # 	loop =C=> finish
        # 
        #         finish: Glow(vex.Color.TRANSPARENT) =T(0.5)=> ParentCompletes()
        # 
        
        # Code generated by genfsm on Sat Jun  7 12:36:33 2025:
        
        showemoji1 = ShowEmoji(vex.EmojiType.HAPPY) .set_name("showemoji1") .set_parent(self)
        playsound1 = PlaySound(vex.SoundType.ACT_HAPPY) .set_name("playsound1") .set_parent(self)
        showemoji2 = ShowEmoji(vex.EmojiType.HAPPY, vex.EmojiLookType.LOOK_RIGHT) .set_name("showemoji2") .set_parent(self)
        glow1 = Glow(vex.Color.YELLOW) .set_name("glow1") .set_parent(self)
        turn1 = Turn(-4, 100) .set_name("turn1") .set_parent(self)
        glow2 = Glow(vex.Color.WHITE) .set_name("glow2") .set_parent(self)
        showemoji3 = ShowEmoji(vex.EmojiType.HAPPY, vex.EmojiLookType.LOOK_LEFT) .set_name("showemoji3") .set_parent(self)
        turn2 = Turn(8, 100) .set_name("turn2") .set_parent(self)
        glow3 = Glow(vex.Color.YELLOW) .set_name("glow3") .set_parent(self)
        showemoji4 = ShowEmoji(vex.EmojiType.HAPPY, vex.EmojiLookType.LOOK_RIGHT) .set_name("showemoji4") .set_parent(self)
        turn3 = Turn(-4, 100) .set_name("turn3") .set_parent(self)
        statenode1 = StateNode() .set_name("statenode1") .set_parent(self)
        loop = Iterate(3) .set_name("loop") .set_parent(self)
        showemoji5 = ShowEmoji(vex.EmojiType.QUIET) .set_name("showemoji5") .set_parent(self)
        glow4 = Glow(vex.Color.WHITE) .set_name("glow4") .set_parent(self)
        movefor1 = MoveFor(1, 90) .set_name("movefor1") .set_parent(self)
        showemoji6 = ShowEmoji(vex.EmojiType.HAPPY) .set_name("showemoji6") .set_parent(self)
        glow5 = Glow(vex.Color.YELLOW) .set_name("glow5") .set_parent(self)
        movefor2 = MoveFor(1, -90) .set_name("movefor2") .set_parent(self)
        finish = Glow(vex.Color.TRANSPARENT) .set_name("finish") .set_parent(self)
        parentcompletes1 = ParentCompletes() .set_name("parentcompletes1") .set_parent(self)
        
        timertrans1 = TimerTrans(0.5) .set_name("timertrans1")
        timertrans1 .add_sources(showemoji1) .add_destinations(playsound1)
        
        timertrans2 = TimerTrans(0.115) .set_name("timertrans2")
        timertrans2 .add_sources(playsound1) .add_destinations(showemoji2)
        
        nulltrans1 = NullTrans() .set_name("nulltrans1")
        nulltrans1 .add_sources(showemoji2) .add_destinations(glow1)
        
        nulltrans2 = NullTrans() .set_name("nulltrans2")
        nulltrans2 .add_sources(glow1) .add_destinations(turn1)
        
        completiontrans1 = CompletionTrans() .set_name("completiontrans1")
        completiontrans1 .add_sources(turn1) .add_destinations(glow2)
        
        nulltrans3 = NullTrans() .set_name("nulltrans3")
        nulltrans3 .add_sources(glow2) .add_destinations(showemoji3)
        
        nulltrans4 = NullTrans() .set_name("nulltrans4")
        nulltrans4 .add_sources(showemoji3) .add_destinations(turn2)
        
        completiontrans2 = CompletionTrans() .set_name("completiontrans2")
        completiontrans2 .add_sources(turn2) .add_destinations(glow3)
        
        nulltrans5 = NullTrans() .set_name("nulltrans5")
        nulltrans5 .add_sources(glow3) .add_destinations(showemoji4)
        
        nulltrans6 = NullTrans() .set_name("nulltrans6")
        nulltrans6 .add_sources(showemoji4) .add_destinations(turn3)
        
        completiontrans3 = CompletionTrans() .set_name("completiontrans3")
        completiontrans3 .add_sources(turn3) .add_destinations(statenode1)
        
        timertrans3 = TimerTrans(0.1) .set_name("timertrans3")
        timertrans3 .add_sources(statenode1) .add_destinations(loop)
        
        datatrans1 = DataTrans() .set_name("datatrans1")
        datatrans1 .add_sources(loop) .add_destinations(showemoji5)
        
        nulltrans7 = NullTrans() .set_name("nulltrans7")
        nulltrans7 .add_sources(showemoji5) .add_destinations(glow4)
        
        nulltrans8 = NullTrans() .set_name("nulltrans8")
        nulltrans8 .add_sources(glow4) .add_destinations(movefor1)
        
        completiontrans4 = CompletionTrans() .set_name("completiontrans4")
        completiontrans4 .add_sources(movefor1) .add_destinations(showemoji6)
        
        nulltrans9 = NullTrans() .set_name("nulltrans9")
        nulltrans9 .add_sources(showemoji6) .add_destinations(glow5)
        
        nulltrans10 = NullTrans() .set_name("nulltrans10")
        nulltrans10 .add_sources(glow5) .add_destinations(movefor2)
        
        cnexttrans1 = CNextTrans() .set_name("cnexttrans1")
        cnexttrans1 .add_sources(movefor2) .add_destinations(loop)
        
        completiontrans5 = CompletionTrans() .set_name("completiontrans5")
        completiontrans5 .add_sources(loop) .add_destinations(finish)
        
        timertrans4 = TimerTrans(0.5) .set_name("timertrans4")
        timertrans4 .add_sources(finish) .add_destinations(parentcompletes1)
        
        return self


class ActSad(ActionNode):
    def setup(self):
        #         ShowEmoji(vex.EmojiType.SAD)                                  =T(0.5)=>
        # 	PlaySound(vex.SoundType.ACT_SAD)                              =T(0.115)=>
        # 
        # 	Glow(vex.LightType.ALL_LEDS, 0, 0, 250)                       =N=>
        #         ShowEmoji(vex.EmojiType.SAD, vex.EmojiLookType.LOOK_RIGHT)    =N=>
        #         MoveFor(11, -135, 70)                                         =C=>
        # 
        # 	Glow(vex.LightType.ALL_LEDS, 0, 0, 100)                       =N=>
        #         ShowEmoji(vex.EmojiType.SAD, vex.EmojiLookType.LOOK_FORWARD)  =N=>
        #         MoveFor(11, -315, 70)                                         =C=>
        # 
        # 	Glow(vex.LightType.ALL_LEDS, 0, 0, 50)                        =N=>
        #         ShowEmoji(vex.EmojiType.SAD, vex.EmojiLookType.LOOK_LEFT)     =N=>
        #         MoveFor(11, 225, 70)                                          =C=>
        # 
        # 	Glow(vex.LightType.ALL_LEDS, 0, 0, 10)                        =N=>
        #         ShowEmoji(vex.EmojiType.SAD, vex.EmojiLookType.LOOK_FORWARD)  =N=>
        #         MoveFor(11, -45, 70)                                          =C=>
        # 
        #         StateNode()                                                   =T(0.5)=>
        #         Glow(vex.LightType.ALL_LEDS, vex.Color.TRANSPARENT)           =N=>
        #         ParentCompletes()
        
        # Code generated by genfsm on Sat Jun  7 12:36:33 2025:
        
        showemoji7 = ShowEmoji(vex.EmojiType.SAD) .set_name("showemoji7") .set_parent(self)
        playsound2 = PlaySound(vex.SoundType.ACT_SAD) .set_name("playsound2") .set_parent(self)
        glow6 = Glow(vex.LightType.ALL_LEDS, 0, 0, 250) .set_name("glow6") .set_parent(self)
        showemoji8 = ShowEmoji(vex.EmojiType.SAD, vex.EmojiLookType.LOOK_RIGHT) .set_name("showemoji8") .set_parent(self)
        movefor3 = MoveFor(11, -135, 70) .set_name("movefor3") .set_parent(self)
        glow7 = Glow(vex.LightType.ALL_LEDS, 0, 0, 100) .set_name("glow7") .set_parent(self)
        showemoji9 = ShowEmoji(vex.EmojiType.SAD, vex.EmojiLookType.LOOK_FORWARD) .set_name("showemoji9") .set_parent(self)
        movefor4 = MoveFor(11, -315, 70) .set_name("movefor4") .set_parent(self)
        glow8 = Glow(vex.LightType.ALL_LEDS, 0, 0, 50) .set_name("glow8") .set_parent(self)
        showemoji10 = ShowEmoji(vex.EmojiType.SAD, vex.EmojiLookType.LOOK_LEFT) .set_name("showemoji10") .set_parent(self)
        movefor5 = MoveFor(11, 225, 70) .set_name("movefor5") .set_parent(self)
        glow9 = Glow(vex.LightType.ALL_LEDS, 0, 0, 10) .set_name("glow9") .set_parent(self)
        showemoji11 = ShowEmoji(vex.EmojiType.SAD, vex.EmojiLookType.LOOK_FORWARD) .set_name("showemoji11") .set_parent(self)
        movefor6 = MoveFor(11, -45, 70) .set_name("movefor6") .set_parent(self)
        statenode2 = StateNode() .set_name("statenode2") .set_parent(self)
        glow10 = Glow(vex.LightType.ALL_LEDS, vex.Color.TRANSPARENT) .set_name("glow10") .set_parent(self)
        parentcompletes2 = ParentCompletes() .set_name("parentcompletes2") .set_parent(self)
        
        timertrans5 = TimerTrans(0.5) .set_name("timertrans5")
        timertrans5 .add_sources(showemoji7) .add_destinations(playsound2)
        
        timertrans6 = TimerTrans(0.115) .set_name("timertrans6")
        timertrans6 .add_sources(playsound2) .add_destinations(glow6)
        
        nulltrans11 = NullTrans() .set_name("nulltrans11")
        nulltrans11 .add_sources(glow6) .add_destinations(showemoji8)
        
        nulltrans12 = NullTrans() .set_name("nulltrans12")
        nulltrans12 .add_sources(showemoji8) .add_destinations(movefor3)
        
        completiontrans6 = CompletionTrans() .set_name("completiontrans6")
        completiontrans6 .add_sources(movefor3) .add_destinations(glow7)
        
        nulltrans13 = NullTrans() .set_name("nulltrans13")
        nulltrans13 .add_sources(glow7) .add_destinations(showemoji9)
        
        nulltrans14 = NullTrans() .set_name("nulltrans14")
        nulltrans14 .add_sources(showemoji9) .add_destinations(movefor4)
        
        completiontrans7 = CompletionTrans() .set_name("completiontrans7")
        completiontrans7 .add_sources(movefor4) .add_destinations(glow8)
        
        nulltrans15 = NullTrans() .set_name("nulltrans15")
        nulltrans15 .add_sources(glow8) .add_destinations(showemoji10)
        
        nulltrans16 = NullTrans() .set_name("nulltrans16")
        nulltrans16 .add_sources(showemoji10) .add_destinations(movefor5)
        
        completiontrans8 = CompletionTrans() .set_name("completiontrans8")
        completiontrans8 .add_sources(movefor5) .add_destinations(glow9)
        
        nulltrans17 = NullTrans() .set_name("nulltrans17")
        nulltrans17 .add_sources(glow9) .add_destinations(showemoji11)
        
        nulltrans18 = NullTrans() .set_name("nulltrans18")
        nulltrans18 .add_sources(showemoji11) .add_destinations(movefor6)
        
        completiontrans9 = CompletionTrans() .set_name("completiontrans9")
        completiontrans9 .add_sources(movefor6) .add_destinations(statenode2)
        
        timertrans7 = TimerTrans(0.5) .set_name("timertrans7")
        timertrans7 .add_sources(statenode2) .add_destinations(glow10)
        
        nulltrans19 = NullTrans() .set_name("nulltrans19")
        nulltrans19 .add_sources(glow10) .add_destinations(parentcompletes2)
        
        return self


class ActSilly(ActionNode):
    class RandomStream(StateNode):
        class RandomLEDs(Glow):
            def start(self, event=None):
                color_list = [vex.Color.BLUE, vex.Color.CYAN, vex.Color.GREEN, vex.Color.ORANGE,
                              vex.Color.PURPLE, vex.Color.RED, vex.Color.WHITE, vex.Color.YELLOW]
                self.args = [vex.LightType.ALL_LEDS, random.choice(color_list)]
                super().start(event)

        class RandomEmoji(ShowEmoji):
            def start(self, event=None):
                emoji_list = [vex.EmojiType.SILLY, vex.EmojiType.HAPPY, vex.EmojiType.EXCITED,
                              vex.EmojiType.PROUD, vex.EmojiType.THRILLED, vex.EmojiType.LAUGHING]
                self.emoji = random.choice(emoji_list)
                super().start(event)

        def setup(self):
            #             start: ShowEmoji(vex.EmojiType.SILLY) =N=>
            #                 self.RandomLEDs() =T(0.110)=>
            #                    self.RandomEmoji() =T(0.110)=> start
            
            # Code generated by genfsm on Sat Jun  7 12:36:33 2025:
            
            start = ShowEmoji(vex.EmojiType.SILLY) .set_name("start") .set_parent(self)
            randomleds1 = self.RandomLEDs() .set_name("randomleds1") .set_parent(self)
            randomemoji1 = self.RandomEmoji() .set_name("randomemoji1") .set_parent(self)
            
            nulltrans20 = NullTrans() .set_name("nulltrans20")
            nulltrans20 .add_sources(start) .add_destinations(randomleds1)
            
            timertrans8 = TimerTrans(0.110) .set_name("timertrans8")
            timertrans8 .add_sources(randomleds1) .add_destinations(randomemoji1)
            
            timertrans9 = TimerTrans(0.110) .set_name("timertrans9")
            timertrans9 .add_sources(randomemoji1) .add_destinations(start)
            
            return self

    def setup(self):
        #         ShowEmoji(vex.EmojiType.HAPPY)                                =T(0.5)=>
        # 	PlaySound(vex.SoundType.ACT_HAPPY)                            =T(0.115)=>
        #         
        #         StateNode() =N=> {turn, random_stream, turn}
        # 
        #         turn: Turn(-360,300)
        #         random_stream: self.RandomStream()
        # 
        #         {turn, random_stream} =C(1)=> finish
        # 
        #         finish: ShowEmoji(vex.EmojiType.SILLY)                        =N=>
        #           Glow(vex.LightType.ALL_LEDS, vex.Color.TRANSPARENT)         =N=>
        #             ParentCompletes()
        
        # Code generated by genfsm on Sat Jun  7 12:36:33 2025:
        
        showemoji12 = ShowEmoji(vex.EmojiType.HAPPY) .set_name("showemoji12") .set_parent(self)
        playsound3 = PlaySound(vex.SoundType.ACT_HAPPY) .set_name("playsound3") .set_parent(self)
        statenode3 = StateNode() .set_name("statenode3") .set_parent(self)
        turn = Turn(-360,300) .set_name("turn") .set_parent(self)
        random_stream = self.RandomStream() .set_name("random_stream") .set_parent(self)
        finish = ShowEmoji(vex.EmojiType.SILLY) .set_name("finish") .set_parent(self)
        glow11 = Glow(vex.LightType.ALL_LEDS, vex.Color.TRANSPARENT) .set_name("glow11") .set_parent(self)
        parentcompletes3 = ParentCompletes() .set_name("parentcompletes3") .set_parent(self)
        
        timertrans10 = TimerTrans(0.5) .set_name("timertrans10")
        timertrans10 .add_sources(showemoji12) .add_destinations(playsound3)
        
        timertrans11 = TimerTrans(0.115) .set_name("timertrans11")
        timertrans11 .add_sources(playsound3) .add_destinations(statenode3)
        
        nulltrans21 = NullTrans() .set_name("nulltrans21")
        nulltrans21 .add_sources(statenode3) .add_destinations(turn,random_stream,turn)
        
        completiontrans10 = CompletionTrans(1) .set_name("completiontrans10")
        completiontrans10 .add_sources(turn,random_stream) .add_destinations(finish)
        
        nulltrans22 = NullTrans() .set_name("nulltrans22")
        nulltrans22 .add_sources(finish) .add_destinations(glow11)
        
        nulltrans23 = NullTrans() .set_name("nulltrans23")
        nulltrans23 .add_sources(glow11) .add_destinations(parentcompletes3)
        
        return self


class ActAngry(ActionNode):
    def setup(self):
        #         ShowEmoji(vex.EmojiType.ANGRY)                                =T(0.5)=>
        # 	PlaySound(vex.SoundType.ACT_ANGRY)                            =T(0.115)=>
        # 
        #         Glow(vex.LightType.ALL_LEDS, vex.Color.RED)                   =N=>
        #         MoveFor(25, 0, 50)                                            =C=>
        #         StateNode()                                                   =T(0.5)=> loop
        # 
        #         loop: Iterate(5)
        #         loop                                                          =D=>
        #           ShowEmoji(vex.EmojiType.ANNOYED)                            =N=>
        #           MoveFor(5, 180, 50)                                         =C=>
        #           ShowEmoji(vex.EmojiType.ANGRY)                              =T(0.05)=>
        #           StateNode()                                                 =Next=> loop
        #         loop =C=> finish
        # 
        #         finish: StateNode()                                           =T(0.5)=>
        #         Glow(vex.LightType.ALL_LEDS, vex.Color.TRANSPARENT)           =N=>
        #         ParentCompletes()
        
        # Code generated by genfsm on Sat Jun  7 12:36:33 2025:
        
        showemoji13 = ShowEmoji(vex.EmojiType.ANGRY) .set_name("showemoji13") .set_parent(self)
        playsound4 = PlaySound(vex.SoundType.ACT_ANGRY) .set_name("playsound4") .set_parent(self)
        glow12 = Glow(vex.LightType.ALL_LEDS, vex.Color.RED) .set_name("glow12") .set_parent(self)
        movefor7 = MoveFor(25, 0, 50) .set_name("movefor7") .set_parent(self)
        statenode4 = StateNode() .set_name("statenode4") .set_parent(self)
        loop = Iterate(5) .set_name("loop") .set_parent(self)
        showemoji14 = ShowEmoji(vex.EmojiType.ANNOYED) .set_name("showemoji14") .set_parent(self)
        movefor8 = MoveFor(5, 180, 50) .set_name("movefor8") .set_parent(self)
        showemoji15 = ShowEmoji(vex.EmojiType.ANGRY) .set_name("showemoji15") .set_parent(self)
        statenode5 = StateNode() .set_name("statenode5") .set_parent(self)
        finish = StateNode() .set_name("finish") .set_parent(self)
        glow13 = Glow(vex.LightType.ALL_LEDS, vex.Color.TRANSPARENT) .set_name("glow13") .set_parent(self)
        parentcompletes4 = ParentCompletes() .set_name("parentcompletes4") .set_parent(self)
        
        timertrans12 = TimerTrans(0.5) .set_name("timertrans12")
        timertrans12 .add_sources(showemoji13) .add_destinations(playsound4)
        
        timertrans13 = TimerTrans(0.115) .set_name("timertrans13")
        timertrans13 .add_sources(playsound4) .add_destinations(glow12)
        
        nulltrans24 = NullTrans() .set_name("nulltrans24")
        nulltrans24 .add_sources(glow12) .add_destinations(movefor7)
        
        completiontrans11 = CompletionTrans() .set_name("completiontrans11")
        completiontrans11 .add_sources(movefor7) .add_destinations(statenode4)
        
        timertrans14 = TimerTrans(0.5) .set_name("timertrans14")
        timertrans14 .add_sources(statenode4) .add_destinations(loop)
        
        datatrans2 = DataTrans() .set_name("datatrans2")
        datatrans2 .add_sources(loop) .add_destinations(showemoji14)
        
        nulltrans25 = NullTrans() .set_name("nulltrans25")
        nulltrans25 .add_sources(showemoji14) .add_destinations(movefor8)
        
        completiontrans12 = CompletionTrans() .set_name("completiontrans12")
        completiontrans12 .add_sources(movefor8) .add_destinations(showemoji15)
        
        timertrans15 = TimerTrans(0.05) .set_name("timertrans15")
        timertrans15 .add_sources(showemoji15) .add_destinations(statenode5)
        
        nexttrans1 = NextTrans() .set_name("nexttrans1")
        nexttrans1 .add_sources(statenode5) .add_destinations(loop)
        
        completiontrans13 = CompletionTrans() .set_name("completiontrans13")
        completiontrans13 .add_sources(loop) .add_destinations(finish)
        
        timertrans16 = TimerTrans(0.5) .set_name("timertrans16")
        timertrans16 .add_sources(finish) .add_destinations(glow13)
        
        nulltrans26 = NullTrans() .set_name("nulltrans26")
        nulltrans26 .add_sources(glow13) .add_destinations(parentcompletes4)
        
        return self


class ActExcited(ActionNode):
    class ExcitedStep(Turn):
        def start(self,event):
            angle = event.data
            leds_actuator = self.robot.actuators['leds']
            if angle < 0:
                look_direction = vex.EmojiLookType.LOOK_RIGHT
                orange_leds = [vex.LightType.LED4, vex.LightType.LED5, vex.LightType.LED6]
            else:
                look_direction = vex.EmojiLookType.LOOK_LEFT
                orange_leds = [vex.LightType.LED1, vex.LightType.LED2, vex.LightType.LED3]
            self.robot.actuators['display'].show_emoji(self, vex.EmojiType.EXCITED, look_direction)
            leds_actuator.set_light_color(self, vex.LightType.ALL_LEDS, vex.Color.TRANSPARENT)
            for ol in orange_leds:
                leds_actuator.set_light_color(self, ol, vex.Color.ORANGE)
            super().start(event)

    def setup(self):
        #         ShowEmoji(vex.EmojiType.EXCITED)                              =T(0.5)=>
        # 	PlaySound(vex.SoundType.ACT_EXCITED)                          =T(0.115)=>
        # 
        #         loop: Iterate([-3, 3, -2, 2, -2, 2, -2, 2, -1, 1])
        #         loop =D=> self.ExcitedStep() =CNext=> loop
        #         loop =C=> finish
        # 
        #         finish: ShowEmoji(vex.EmojiType.EXCITED)                      =N=>
        #         Glow(vex.Color.TRANSPARENT)                                   =N=>
        #         StateNode()                                                   =T(0.5)=>
        #         ParentCompletes()        
        
        # Code generated by genfsm on Sat Jun  7 12:36:33 2025:
        
        showemoji16 = ShowEmoji(vex.EmojiType.EXCITED) .set_name("showemoji16") .set_parent(self)
        playsound5 = PlaySound(vex.SoundType.ACT_EXCITED) .set_name("playsound5") .set_parent(self)
        loop = Iterate([-3, 3, -2, 2, -2, 2, -2, 2, -1, 1]) .set_name("loop") .set_parent(self)
        excitedstep1 = self.ExcitedStep() .set_name("excitedstep1") .set_parent(self)
        finish = ShowEmoji(vex.EmojiType.EXCITED) .set_name("finish") .set_parent(self)
        glow14 = Glow(vex.Color.TRANSPARENT) .set_name("glow14") .set_parent(self)
        statenode6 = StateNode() .set_name("statenode6") .set_parent(self)
        parentcompletes5 = ParentCompletes() .set_name("parentcompletes5") .set_parent(self)
        
        timertrans17 = TimerTrans(0.5) .set_name("timertrans17")
        timertrans17 .add_sources(showemoji16) .add_destinations(playsound5)
        
        timertrans18 = TimerTrans(0.115) .set_name("timertrans18")
        timertrans18 .add_sources(playsound5) .add_destinations(loop)
        
        datatrans3 = DataTrans() .set_name("datatrans3")
        datatrans3 .add_sources(loop) .add_destinations(excitedstep1)
        
        cnexttrans2 = CNextTrans() .set_name("cnexttrans2")
        cnexttrans2 .add_sources(excitedstep1) .add_destinations(loop)
        
        completiontrans14 = CompletionTrans() .set_name("completiontrans14")
        completiontrans14 .add_sources(loop) .add_destinations(finish)
        
        nulltrans27 = NullTrans() .set_name("nulltrans27")
        nulltrans27 .add_sources(finish) .add_destinations(glow14)
        
        nulltrans28 = NullTrans() .set_name("nulltrans28")
        nulltrans28 .add_sources(glow14) .add_destinations(statenode6)
        
        timertrans19 = TimerTrans(0.5) .set_name("timertrans19")
        timertrans19 .add_sources(statenode6) .add_destinations(parentcompletes5)
        
        return self
